/*
 * AuxiliaryActivity.cpp
 *
 *  Created on: 19 Aug 2011
 *      Author: Allan
 */

#include "AuxiliaryActivity.h"

// C++ includes
#include <algorithm>
using namespace std;
using namespace std::placeholders;

// Boost includes
#include <boost/foreach.hpp>

// GeoReact includes
#include "Utils/Algorithms.h"

AuxiliaryActivity::AuxiliaryActivity()
{}

AuxiliaryActivity::AuxiliaryActivity(const vector<string>& species) :
species(species)
{}

AuxiliaryActivity::AuxiliaryActivity(const vector<string>& species, const ActivityCoefficient& activitycoeff) :
species(species), activitycoeffs(species.size(), activitycoeff)
{}

AuxiliaryActivity::~AuxiliaryActivity()
{}

void AuxiliaryActivity::SetActivityCoefficient(const string& s, const ActivityCoefficient& activitycoeff)
{
	// Get the index of the species (s)
	const unsigned i = IndexOf(s, species);
	
	// Set the activity coefficient of the given species (s)
	if(i < species.size())
		activitycoeffs[i] = activitycoeff;
}

const VectorXd AuxiliaryActivity::ActivityCoefficients(double T, double P, const VectorXd& n) const
{
	VectorXd g(n.rows());
	
	for(int i = 0; i < g.rows(); ++i) g[i] = activitycoeffs[i](T, P, n);
	
	return g;
}

